package com.cn.wanxi.util.servlet;

import com.cn.wanxi.util.model.AboutNavModel;
import com.cn.wanxi.util.model.CommunalTitle;
import com.cn.wanxi.util.model.CourseModel;
import com.cn.wanxi.util.service.impl.AboutNavService;
import com.cn.wanxi.util.service.impl.CourseService;
import com.cn.wanxi.util.service.impl.HeaderService;
import com.cn.wanxi.util.service.impl.NewsService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/CourseElementaryServlet")
public class CourseElementaryServlet extends HomeServletServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//        super.doGet(req, resp);
        AboutNavService aboutNavService =new AboutNavService();
        HeaderService headerService =new HeaderService();
        CourseService courseService =new CourseService();
//        页面小导航
        List<AboutNavModel> aboutNavModels =aboutNavService.getaboutNavM();
        req.setAttribute("aboutNavModels",aboutNavModels);

//        内容标题
        List<CommunalTitle> communalTitles = headerService.getCommunalTitle();
        req.setAttribute("communalTitles",communalTitles);

        //课程内容
        List<CourseModel> courseModels = courseService.getcourseModel();
        req.setAttribute("courseModels",courseModels);
        gotoCourseElementary(req,resp);

    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        gotoCourseElementary(req,resp);
    }
    private void gotoCourseElementary(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.getRequestDispatcher("/jsp/Course-elementary.jsp").forward(req,resp);
    }
}
